package com.common.retrofit.methods;

import com.common.cons.Constans;
import com.common.retrofit.base.BaseMethods;
import com.common.retrofit.service.HaiNingService;
import com.common.utils.SortUtils;

import rx.Observable;
import rx.Subscriber;

public class GetCodeMethods extends BaseMethods {

    private static GetCodeMethods m_ins = null;

    public static GetCodeMethods getInstance() {
        if (m_ins == null) {
            synchronized (GetCodeMethods.class) {
                if (m_ins == null) {
                    m_ins = new GetCodeMethods();
                }
            }
        }
        return m_ins;
    }

    @Override
    protected String getHttpUrl() {
        return "api/Sms/";
    }

    private HaiNingService initService() {
        return getRetrofit().create(HaiNingService.class);
    }


    public void     getCode(Subscriber<Object> subscriber,
                      String mobile,
                      String checktype ) {
        String time  = System.currentTimeMillis()+"" ;
        Observable observable = initService().getCode(time,
                SortUtils.getMyHash("mobile"+mobile,"type"+checktype ,"time"+time), Constans.ANDROID_APP_ID,"3",mobile,checktype
        );
        toSubscribe(observable, subscriber);
    }
}
